package com.yuntuzhilian.chapter3.demo2;

/**
 * @author MrWang-shuizhishuiheshui
 * @description
 */
public class Penguin {

    //属性私有化
    private String sex;
    private int age;

    public Penguin() {
    }
    public Penguin(String sex, int age) {
        this();
        this.sex = sex;
        this.age = age;
    }

    //添加公共的getter和setter方法
    //传值
    public void setSex(String sex){
        this.sex=sex;
    }
    //取值
    public String getSex(){
        return sex;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        if (age>=0){
            this.age = age;
        }else{
            System.out.println("你是个憨憨~~");
        }

    }

    //方法
    public void show(){
        System.out.println(sex+age);
    }


}
